<template>
  <div class="dashboard-container">
    <div class="dashboard-text">name: {{ userName }}</div>
    <el-button type="primary" @click="addRoutes">演示动态路由</el-button>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'

export default {
  name: 'Dashboard',
  computed: {
    ...mapGetters([
      'userName'
    ])
  },
  methods: {
    addRoutes() {
      // 要根据后端返回的权限信息，结合本地动态路由表，筛选出当前用户有权访问的路由
      // 将有权访问的路由动态添加到路由对象中，使用addRoutes方法，将筛选出当前用户有权访问的路由添加到路由对象中
      this.$router.addRoutes([
        {
          path: '/abcd',
          name: '/abcd',
          component: () => import('./abc.vue')
        }
      ])
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
  &-text {
    font-size: 30px;
    line-height: 46px;
  }
}
</style>
